package com.yiren.dbaa.currency.dialog;

import android.content.Context;
import android.content.DialogInterface;

import com.yiren.dbaa.view.dialog.CustomDialog;

/**
 * 通用对话框
 */
public class CommonDialog {

    /**
     * 通用弹出框
     * @param context
     * @param title    标题
     * @param message  提示内容
     * @param listener 确定监听
     */
    public static void show(Context context, String title, String message, DialogInterface.OnClickListener listener) {
        CustomDialog.Builder builder = new CustomDialog.Builder(context);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setCanceled(false);
        builder.setUpApk(true);
        builder.setPositiveButton("确定", listener);
        builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());
        builder.create().show();
    }

    /**
     * 显示一个按钮的弹出框
     * @param context  上下文
     * @param title   标题
     * @param message  文本内容
     * @param btName  确认按钮
     * @param listener  监听
     */
    public static void showOneBtn(Context context, String title, String message, String btName, DialogInterface.OnClickListener listener) {
        CustomDialog.Builder builder = new CustomDialog.Builder(context);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setCanceled(false);
        builder.setPositiveButton(btName, listener);
        builder.create().show();
    }

    /**
     * 显示两个按钮的弹出框
     * @param context 上下文
     * @param title   标题
     * @param message  文本内容
     * @param btName1  取消按钮
     * @param btName2  确认按钮
     * @param listener 点击监听
     */
    public static void showTwoBtn(Context context, String title, String message, String btName1, String btName2, DialogInterface.OnClickListener listener) {
        CustomDialog.Builder builder = new CustomDialog.Builder(context);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setCanceled(false);
        builder.setNegativeButton(btName1, listener);
        builder.setPositiveButton(btName2, listener);
        builder.create().show();
    }
}
